/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package MyComparator;
import java.util.Comparator;
import java.util.Map;

/**
 *
 * @author yichao
 */


public class CompareDouble implements Comparator<Object>{

	@SuppressWarnings("unchecked")
	public int compare(Object obj1, Object obj2){
		int result=0;
		Map.Entry e1 = (Map.Entry)obj1 ;
		Map.Entry e2 = (Map.Entry)obj2 ;
		//Sort based on values.

		Double value1 = (Double)e1.getValue();
		Double value2 = (Double)e2.getValue();


		//Sort values in a descending order
		result=value2.compareTo( value1 );
		return result;
	}
}
